// Learn cc.Class:
//  - https://docs.cocos.com/creator/2.4/manual/en/scripting/class.html
// Learn Attribute:
//  - https://docs.cocos.com/creator/2.4/manual/en/scripting/reference/attributes.html
// Learn life-cycle callbacks:
//  - https://docs.cocos.com/creator/2.4/manual/en/scripting/life-cycle-callbacks.html

cc.Class({
    extends: cc.Component,

    properties: {
        // foo: {
        //     // ATTRIBUTES:
        //     default: null,        // The default value will be used only when the component attaching
        //                           // to a node for the first time
        //     type: cc.SpriteFrame, // optional, default is typeof default
        //     serializable: true,   // optional, default is true
        // },
        // bar: {
        //     get () {
        //         return this._bar;
        //     },
        //     set (value) {
        //         this._bar = value;
        //     }
        // },
    },

    // LIFE-CYCLE CALLBACKS:

    // onLoad () {},

    start () {
        //cc.director.preloadScene("game");


        //cc.assetManager.loadBundle("scene_subpackage");

    },

    loginClick(){
        // cc.director.loadScene("game");

        cc.assetManager.loadBundle("res", (err, bundle) => {
        if (err) {
            console.error("子包加载失败:", err);
            return;
        }

        cc.assetManager.loadBundle("Scene", (err, bundle) => {
        if (err) {
            console.error("子包加载失败:", err);
            return;
        }

        // 2. 加载子包中的场景
        bundle.loadScene("game", (err, scene) => {
            if (err) {
                console.error("场景加载失败:", err);
                return;
            }

            // 3. 切换场景（可选：添加过渡动画）
            cc.director.runSceneImmediate(scene, false); // 立即切换，不清理缓存
        });
    });
    });

        
    }

    // update (dt) {},
});
